﻿Imports System.Resources

Public Class frmDataChoix


    Private rm As New ResourceManager(GetType(frmDataChoix))

    Private Sub BtnObservation_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PtcDataObs.Click
        FormMain.obervationsType = "current"
        frmEntryChoixProtocol.previousStep = "Data"
        frmEntryChoixProtocol.Show()
        Me.Hide()
    End Sub

    Private Sub btn_Menu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMenu.Click
        FormMain.Show()
        Me.Hide()
    End Sub

    Public Sub CreateObservationTable()
        Try
            If FormMain.oListObs.lstStations.Count > 0 Then
                frmDataObsTable.dgGrid2.DataSource = ExportListObsToDataTable(oProtocolsCurrentListObs, frmEntryChoixProtocol.selectedProtocolId)
            Else
                frmDataObsTable.dgGrid2.DataSource = Nothing
            End If
        Catch ex As Exception
            Throw New Exception(ex.Message)
        End Try
    End Sub


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        frmUtilityChronometer.Show()
        Me.Hide()

    End Sub

    Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PctDataImg.Click
        Try
            Me.CreatePictureTable()
            frmDataPictureTable.Show()
            Me.Hide()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical, "Pocket eReleve")
        End Try
    End Sub

    Public Sub CreatePictureTable()
        Try
            If oCurrentListImg.lstImg.Count > 0 Then
                frmDataPictureTable.dgGrid2.DataSource = ExportListPictureToDataTable()
            Else
                frmDataPictureTable.dgGrid2.DataSource = Nothing
            End If
        Catch ex As Exception
            Throw New Exception(ex.Message)
        End Try
    End Sub

    Private Sub PtcOldDataObs_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PtcOldDataObs.Click
        Try
            FormMain.obervationsType = "old"
            OpenFileDialog1.InitialDirectory = FormMain.NSDossier
            OpenFileDialog1.Filter = "Fichiers nsml|RecupObs_*.nsml"
            OpenFileDialog1.ShowDialog()
            Dim sFilePath = OpenFileDialog1.FileName
            Dim strlengh As Short = sFilePath.ToString.Length
            Dim strProtName As String = sFilePath.ToString.Substring(34, strlengh - 46)
            Dim strVerifFile As String = sFilePath.ToString.Substring(25, 9)
            If strVerifFile = "RecupObs_" Then
                Cursor.Current = Cursors.WaitCursor
                If IsNothing(frmEntryChoixProtocol.olistProtocoles) Then
                    frmEntryChoixProtocol.olistProtocoles = New clsProtocolesList(FormMain.NSDossier & "XML_ProtocolDef.xml")
                End If

                oProtocolsOldListObs = Nothing
                oProtocolsOldListObs = New Hashtable

                Dim oListOldObs As ClsListObservations
                oListOldObs = New ClsListObservations(CType(sFilePath, String))

                ' recuperer nom du prot
                oProtocolsOldListObs.Add(strProtName, oListOldObs)
                'frmEntryChoixProtocol.selectedProtocolId = strProtName

                Dim succeed As Boolean = frmDataObsTable.initDataGrid(oProtocolsOldListObs, strProtName)
                If succeed Then
                    ' frmDataObsTable.previous = Me.Name
                    frmDataObsTable.Show()
                    Me.Hide()
                End If

                Cursor.Current = Cursors.Default
            Else
                MsgBox(My.Resources.Images.selectedFileName, MsgBoxStyle.Exclamation)
                Exit Sub
            End If


        Catch ex As Exception
            MsgBox(My.Resources.Images.fileLoadCanceled, MsgBoxStyle.Exclamation, "Pocket eRelevé")
            ' MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Pocket eRelevé")
        End Try

    End Sub
End Class